# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import requests


def single_segment(uri_str, i):
    proxies = {
        "https": "127.0.0.1:53934",
    }

    headers = {
        'authority': 'vod8eu11.128100.xyz',
        'method': 'GET',
        'path': '/hls/qWNVQCETQ3T/' + uri_str,
        'scheme': 'https',
        'accept': '*/*',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
        'origin': 'https://cableav.tv',
        'referer': 'https://cableav.tv/',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'cross-site',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
    }
    # url = 'https://vod8eu5.128100.xyz/hls/qWNVQCETQ3T/CLS-27-v1-a1.ts?ip=47.242.233.182&exp=1609465572&hash=3d8ebe05eba0fa511c1e95826eaaf7b1'  https://3hmhjf.qise100.com/video/view/07bcd70d364f69dcbee2
    url = 'https://vod8eu11.128100.xyz/hls/qWNVQCETQ3T/' + uri_str
    print(url)
    r = requests.get(url=url, headers=headers, proxies=proxies)
    print(r.status_code)
    print(r.text)
    f = open("d:/ffmpeg/ts/%06d.ts" % i, "wb")
    f.write(r.content)
    f.close()

# https://3hmhjf.qise100.com/video/view/190290210      https://3hmhjf.qise100.com/video/view/1708766759   https://3hmhjf.qise100.com/video/view/ae6665fbe72c59537bc0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    uri='CLS-21-v1-a1.ts?ip=47.242.233.182&exp=1609465572&hash=37271c2b9c0d146556bbe0e43313d72b'
    i=1
    single_segment(uri,i)

